package com.xdxc.emuns;

public enum QuestionType {
    SINGLE_CHOICE(1, "SINGLE_CHOICE"),
    MULTIPLE_CHOICE(2, "MULTIPLE_CHOICE"),
    JUDGMENT(3, "JUDGMENT"),
    FILL_BLANK(4, "FILL_BLANK"),
    PROGRAMMING(5, "PROGRAMMING");

    private final int code;
    private final String desc;

    // Corrected constructor
    QuestionType(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    // Renamed to getByCode and returns QuestionType
    public static QuestionType getName(int code) {
        for (QuestionType c : QuestionType.values()) {
            if (c.code == code) {
                return c;
            }
        }
        return null;
    }

    // Getter methods
    public int getCode() {
        return code;
    }

    public static Integer getCodeByDesc(String desc) {
        for (QuestionType c : QuestionType.values()) {
            if (c.desc.equals(desc)) {
                return c.code;
            }
        }
        return null;
    }

    public String getDesc() {
        return desc;
    }
}